import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;


public class MapMain {

	public static void main(String[] args) {
		Map<String,Integer> map = new HashMap<String,Integer>();
		map.put("Zou Encen", new Integer(3));
		map.put("Lucy", new Integer(5));
		map.put("Jim", new Integer(5));
		map.put("Lily", new Integer(4));
		map.put("Liu Rui", new Integer(3));
		map.put("Li Xiaohong", new Integer(0));
		String key = "Liu Rui";
		Integer value = null;
		if (map.containsKey(key))
		{
			value = map.get(key);
			System.out.println("Use key:" + key + " find value:" + value);
		}
		else
		{
			System.out.println("Does not contain key:" + key);
		}
		 key = "Zou Encen";
		value = null;
		if (map.containsKey(key))
		{
			value =  map.get(key);
			System.out.println("Use key:" + key + " find value:" + value);
		}
		else
		{
			System.out.println("Does not contain key:" + key);
		}
		key = "tom";
		if (map.containsKey(key))
		{
			value =  map.get(key);
			System.out.println("Use key:" + key + " find value:" + value);
		}
		else
		{
			System.out.println("Does not contain key:" + key);
		}
		
		Iterator it = map.entrySet().iterator();
		Map.Entry entry = (Map.Entry) it.next();
        key= (String) entry.getKey();
        value=(Integer) entry.getValue();
       System.out.println("Use iterator to get the first entry is Key :"+key+"  Value :"+value);
        while(it.hasNext()) {
		entry = (Map.Entry) it.next();
        key=(String) entry.getKey();
        value=(Integer) entry.getValue();
        System.out.println("Use iterator to get the second entry is Key :"+key+"  Value :"+value);
        }
	}

}
